package com.yafeng.logic.controller;


import com.yafeng.comonutils.ApiResult;
import com.yafeng.logic.entity.BaoRbacRole;
import com.yafeng.logic.service.BaoRbacRoleService;
import com.yafeng.logic.vo.QueryRoleList;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author cn.classbao
 * @since 2020-08-19
 */
@RestController
@RequestMapping("/rbac-role")
public class BaoRbacRoleController {

    @Autowired
    private BaoRbacRoleService baoRbacRoleService;

    /**
     * 获取权限列表
     * @param queryRoleList
     * @return
     */
    @GetMapping("query-rolelist")
    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })
    public ApiResult queryRoleList(QueryRoleList queryRoleList){

        ApiResult apiResult = baoRbacRoleService.queryRoleList(queryRoleList);
        return apiResult;
    }
    /**
     * 获取父权限列表
     * @return
     */
    @GetMapping("query-roles-far")
    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })
    public ApiResult queryRolesFar(){

        ApiResult apiResult = baoRbacRoleService.queryRolesFar();

        return apiResult;


    }
    /**
     * 添加roleitem
     * @return
     */
    @PostMapping("create-role-item")
    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })
    public ApiResult createRoleItem(@RequestBody BaoRbacRole baoRbacRole){

        ApiResult apiResult = baoRbacRoleService.createRoleItem(baoRbacRole);

        return apiResult;


    }

    /**
     * 删除roleitem
     * @return
     */
    @DeleteMapping("del-role-item")
    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })
    public ApiResult delRoleItem(@RequestBody Integer [] ids){

        ApiResult apiResult = baoRbacRoleService.delRoleItem(ids);

        return apiResult;


    }


    /**
     * 修改角色
     * @param
     * @return
     */
    @PostMapping("update-role-item")
    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })
    public ApiResult updateRoleItem(@RequestBody BaoRbacRole baoRbacRole){

        ApiResult apiResult = baoRbacRoleService.updateRoleItem(baoRbacRole);

        return apiResult;


    }

    /**
     * 通过父id获取角色列表
     * @param fid
     * @return
     */
    @GetMapping("query-role-itemByFid")
    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })
    public ApiResult queryRoleItemByFid(Integer fid){

        ApiResult apiResult = baoRbacRoleService.queryRoleItemByFid(fid);

        return apiResult;


    }

    /**
     *
     * 配置角色获取角色数"
     * @return
     */
    @GetMapping("query-role-tree-list")
    @ApiOperation("配置角色获取角色数")
    public ApiResult queryRoleTreeList(){

        return baoRbacRoleService.queryRoleTreeList();

    }

}

